﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 工序管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessManagController : ControllerBase
    {
        // GET: api/<ProcessManagController>
        private readonly IProcessManagServices ProcessManagServices;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ProcessManagServices"></param>
        public ProcessManagController(IProcessManagServices ProcessManagServices)
        {
            this.ProcessManagServices = ProcessManagServices;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddProcessManag(ProcessManagModel model)
        {
            return ProcessManagServices.AddProcessManag(model);
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ProcessManagOut>> GetProcessManag([FromQuery] QryInput qryInput)
        {
            return ProcessManagServices.GetProcessManag(qryInput);
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ProcessManagOut>> GetProcessManagNew([FromQuery] QryInput qryInput)
        {
            return ProcessManagServices.GetProcessManagNew(qryInput);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdatProcessManag(ProcessManagModel model)
        {
            return ProcessManagServices.UpdateProcessManag(model);
        }

        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(ProcessManagModel model)
        {
            return ProcessManagServices.UpdateEnable(model);
        }


        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="PCId"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(string PCId)
        {
            return ProcessManagServices.UpdateDelete(PCId);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="PCId"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetPMId(string PMId)
        {
            return ProcessManagServices.GetPMId(PMId);
        }
    }
}
